﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/MobileMasterPage.master" AutoEventWireup="true" CodeFile="NewWishNote.aspx.cs" Inherits="M_NewWishNote" %>
<%@ MasterType VirtualPath="~/MasterPage/MobileMasterPage.master" %>

<asp:Content ID="Content4" ContentPlaceHolderID="JqMobilePlaceHolder1" Runat="Server">
    <link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~/css/jquery.mobile-1.4.5.min.css") %>" />      
    <script src='<%=ResolveUrl("~/Scripts/jquery.mobile-1.4.5.min.js")%>' type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="headPlaceHolder" Runat="Server">
<style type="text/css">
    #form_table
    {
        width:100%;
        border-collapse: collapse;
        empty-cells: show;
    }
    #form_table tr .td1
    {
        width:80px;
        padding-left:10px;
    }
    #form_table tr .td2
    {
        width:auto;
        padding-right:10px;
    }
    .tdb
    {
        padding:20px 20px 0px 20px; 
    }
    .error_text
    {
        color:Red;
        display: none;
        font-size:12px;
        margin-bottom:5px;
    }
</style>
<script type="text/javascript">
    jQuery(document).ready(
        function () {

        }
    );
    var set_error_text = function (span_object, messag) {
        jQuery(".error_text").css("display", "none");
        $(span_object).css("display", "block");
        $(span_object).html(messag);
    }
    var isInteger = function (s) {
        //检测字符是否为数字
        var pattern = /^([-]){0,1}([0-9]){1,}([.]){0,1}([0-9]){0,}$/;
        if (!pattern.test(s))
            return false;
        return true;
    }
    var check_name_tb = function () {
        if (jQuery("#name_tb").val().length == 0) {
            set_error_text(jQuery("#cname_tb"), "请输入您的姓名");
            return false;
        }
        return true;
    }
    var check_toname_tb = function () {
        if (jQuery("#toname_tb").val().length == 0) {
            set_error_text(jQuery("#ctoname_tb"), "请问您要祝福谁");
            return false;
        }
        return true;

    }
    var check_qq_tb = function () {
        if (jQuery("#qq_tb").val().length == 0) {
            set_error_text(jQuery("#cqq_tb"), "请留下你的QQ");
            return false;
        }
        if (!isInteger(jQuery("#qq_tb").val())) {
            set_error_text(jQuery("#cqq_tb"), "QQ必须为数字!");
            return false;
        }
        return true;

    }
    var check_lei_ddl = function () {
        if (jQuery("[id$=lei_ddl]").val() == 0) {
            set_error_text(jQuery("#clei_ddl"), "请选择祝福类型");
            return false;
        }
        return true;
    }
    var check_game_tb = function () {
        if (jQuery("#game_tb").val().length == 0) {
            set_error_text(jQuery("#cgame_tb"), "请输入祝福语");
            return false;
        }
        if (jQuery("[id$=game_tb]").val().length > 45) {
            set_error_text(jQuery("#cgame_tb"), "只能输入不多于45个字");
            return false;
        }
        return true;

    }
    var check_submit = function () {
        if (!check_name_tb())
            return false;
        if (!check_toname_tb())
            return false;
        if (!check_qq_tb())
            return false;
        if (!check_lei_ddl())
            return false;
        if (!check_game_tb())
            return false;
        this.disabled = true;
        return true;
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="headerPlaceHolder" Runat="Server">
    <a href="<%=ResolveUrl("~/m/WishingWall.aspx")%>" data-role="button" data-icon="arrow-l" data-iconpos="notext" data-ajax="false" style=" margin-left:5px;">左箭头按钮</a>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="contentPlaceHolder" Runat="Server">
<asp:HiddenField ID="zhuantiID_hf" runat="server" />
<table id="form_table">
    <tr>
        <td class="td1">您的姓名：
        </td>
        <td class="td2">
            <input name="name_tb" type="text" value="匿名" maxlength="8" id="name_tb" onclick="if(this.value =='匿名') this.value='';" />
            <span id="cname_tb" class="error_text"></span>
        </td>
    </tr>
    <tr>
        <td class="td1">要祝福谁：
        </td>
        <td class="td2">
            <input name="toname_tb" type="text" maxlength="8" id="toname_tb" />
            <span id="ctoname_tb" class="error_text"></span>
        </td>
    </tr>
    <tr>
        <td class="td1">您的QQ：
        </td>
        <td class="td2">
            <input name="qq_tb" maxlength="13" id="qq_tb" type="number" />
            <span id="cqq_tb" class="error_text"></span>
        </td>
    </tr>
    <tr>
        <td class="td1">选择类型：
        </td>
        <td class="td2">
            <asp:DropDownList ID="lei_ddl" runat="server">
            </asp:DropDownList>
            <span id="clei_ddl" class="error_text"></span>
        </td>
    </tr>
    <tr>
        <td class="td1">祝福语：
        </td>
        <td class="td2">
            <textarea name="game_tb" rows="2" cols="20" id="game_tb" maxlength="45"></textarea>
            <span id="cgame_tb" class="error_text"></span>
        </td>
    </tr>
    <tr>
        <td colspan="2" class="tdb">
            <asp:Button ID="submit_btn" runat="server" Text="保存我的愿望" OnClick="submit_btn_Click" OnClientClick="return check_submit();"/>
        </td>
    </tr>
</table>
</asp:Content>

